package com.inspur.ehcache.config;

import net.sf.ehcache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 方式一：手动加载ehcache配置文件返回 EhCacheManager
 */
@Configuration
public class EHcacheConfig {

    @Bean
    public CacheManager manager(){
        CacheManager cacheManager = CacheManager.getCacheManager("enCacheManager");
        if (cacheManager == null){
            cacheManager = new CacheManager("./src/main/resources/ehcache.xml");
        }
        return cacheManager;
    }
}

